<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/6 0006
  Time: 15:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="../inc/header.jsp"></jsp:include>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=3dCSZTAzCo0WOb1OnIIsZQfMvplfa0wZ"></script>

<%--///////////////////////////////--%>
<!-- Page Heading Section Start -->
<div class="page-heading-section section bg-parallax" data-bg-image="<%=path%>/assets/images/bg/bg-1.jpg" data-overlay="50">
    <div class="container">
        <div class="page-heading-content text-center">
            <h3 class="title">${company.companyName}</h3>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="index.html">网站首页</a></li>
                <li class="breadcrumb-item"><a href="<%=path%>/web/company/companyList">公司列表</a></li>
                <li class="breadcrumb-item active">${company.companyName}</li>
            </ol>
        </div>
    </div>
</div>
<!-- Page Heading Section End -->
<%--///////////////////////////////--%>
<!-- Company List Start -->
<div class="section section-padding">
    <div class="container">
        <div class="row mb-n5">

            <div class="col-lg-8 col-12 mb-5 pr-lg-5">

                <!-- Company Details Start -->
                <div class="company-details">
                    <h5 class="mb-3">关于 ${requestScope.company.companyName}</h5>

                    <p>简介：${company.intro}</p>
<%--                    <input type="text" name="address" id="suggestId">--%>
<%--                    <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>--%>
<%--                    <div id="l-map" style="width: 500px"></div>--%>
                </div>
                <!-- Company Details Start -->
                <br><br><br><br>
                <strong>公司岗位信息</strong>
                <!-- Job List Wrap Start -->
                <div class="job-list-wrap mt-5">

                    <c:forEach items="${requestScope.pageInfo.list}" var="companyPosition">
                        <!-- Job List Start -->
                        <a href="<%=path%>/web/job/single?CPId=${companyPosition.id}" class="job-list">
                            <div class="company-logo col-auto">
                                <img src="<%=path%>/assets/images/companies/company-1.png" alt="Company Logo">
                            </div>
                            <div class="salary-type col-auto order-sm-3">
                                <span class="salary-range">$${companyPosition.salaryMin} - $${companyPosition.salaryMax}</span>
                                <c:if test="${companyPosition.positionAttr.id eq 1}">
                                    <span class="badge badge-warning">${companyPosition.positionAttr.attr}</span>
                                </c:if>
                                <c:if test="${companyPosition.positionAttr.id eq 2}">
                                    <span class="badge badge-success">${companyPosition.positionAttr.attr}</span>
                                </c:if>
                                <c:if test="${companyPosition.positionAttr.id eq 3}">
                                    <span class="badge badge-info">${companyPosition.positionAttr.attr}</span>
                                </c:if>
                                <c:if test="${companyPosition.positionAttr.id eq 4}">
                                    <span class="badge badge-danger">${companyPosition.positionAttr.attr}</span>
                                </c:if>

                            </div>
                            <div class="content col">
                                <h6 class="title">${companyPosition.name}</h6>
                                <ul class="meta">
                                    <li><strong class="text-primary">${companyPosition.company.companyName}</strong></li>
                                    <li><i class="fa fa-map-marker"></i> 2020 ${companyPosition.city.cityName}, ${companyPosition.company.address}</li>
                                </ul>
                            </div>
                        </a>
                        <!-- Job List Start -->
                    </c:forEach>

                    <!-- 分页 -->
                    <!-- Pagination Start -->
                    <ul class="pagination pagination-center mt-5">

                        <li class="page-item"><a class="page-link" id="prePage" data-id="${requestScope.pageInfo.pageNum-1}"><i class="fa fa-angle-left"></i></a></li>

                        <c:if test="${requestScope.pageInfo.pages>=5}">
                            <c:if test="${requestScope.pageInfo.pageNum>=3 && requestScope.pageInfo.pageNum<=requestScope.pageInfo.pages-2}">
                                <c:forEach begin="${requestScope.pageInfo.pageNum-2}" end="${requestScope.pageInfo.pageNum+2}" var="stat">
                                    <c:if test="${stat eq requestScope.pageInfo.pageNum}">
                                        <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                                    </c:if>
                                    <c:if test="${stat ne requestScope.pageInfo.pageNum}">
                                        <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                                    </c:if>
                                </c:forEach>
                            </c:if>
                            <c:if test="${requestScope.pageInfo.pageNum<3}">
                                <c:forEach begin="1" end="5" var="stat">
                                    <c:if test="${stat eq requestScope.pageInfo.pageNum}">
                                        <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                                    </c:if>
                                    <c:if test="${stat ne requestScope.pageInfo.pageNum}">
                                        <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                                    </c:if>
                                </c:forEach>
                            </c:if>
                            <c:if test="${requestScope.pageInfo.pageNum>requestScope.pageInfo.pages-2}">
                                <c:forEach begin="${requestScope.pageInfo.pages-4}" end="${requestScope.pageInfo.pages}" var="stat">
                                    <c:if test="${stat eq requestScope.pageInfo.pageNum}">
                                        <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                                    </c:if>
                                    <c:if test="${stat ne requestScope.pageInfo.pageNum}">
                                        <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                                    </c:if>
                                </c:forEach>
                            </c:if>
                        </c:if>
                        <c:if test="${requestScope.pageInfo.pages<5}">
                            <c:forEach begin="1" end="${requestScope.pageInfo.pages}" var="stat">
                                <c:if test="${stat eq requestScope.pageInfo.pageNum}">
                                    <li class="page-item active"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                                </c:if>
                                <c:if test="${stat ne requestScope.pageInfo.pageNum}">
                                    <li class="page-item"><a class="page-link" id="page${stat}" data-id="${stat}">${stat}</a></li>
                                </c:if>
                            </c:forEach>
                        </c:if>

                        <li class="page-item"><a class="page-link" id="nextPage" data-id="${requestScope.pageInfo.pageNum+1}"><i class="fa fa-angle-right"></i></a></li>

                    </ul>
                    <!-- Pagination End -->

                </div>
                <!-- Job List Wrap Start -->

            </div>

            <!-- Company Sidebar Wrap Start -->
            <div class="col-lg-4 col-12 mb-5">
                <div class="sidebar-wrap">
                    <!-- Sidebar (Company) Start -->
                    <div class="sidebar-widget">
                        <div class="inner">
                            <div class="sidebar-company">
                                <span class="company-logo"><img src="<%=path%>/assets/images/companies/${requestScope.company.logo}" alt="company-1"></span>
                                <h6 class="title">${requestScope.company.companyName}</h6>
                                <ul>
                                    <c:if test="${requestScope.companyAuthc.isPass eq true}">
                                        <li><strong>公司审核:</strong>  <font color="#7cfc00">已通过</font></li>
                                    </c:if>
                                    <c:if test="${requestScope.companyAuthc.isPass ne true}">
                                        <li><strong>公司审核:</strong>  <font color="red">未通过</font></li>
                                    </c:if>
                                    <li><strong>公司规模:</strong> ${requestScope.company.scope}</li>
                                    <li><strong>所在城市:</strong> ${requestScope.company.city.cityName}</li>
                                    <li><strong>公司地址:</strong> ${requestScope.company.address}</li>
                                    <li><strong>官网:</strong> <a href="">${requestScope.company.website}</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <!-- Sidebar (Company) End -->

                    <!-- Sidebar (Company Location) Start -->
                    <div class="sidebar-widget">
                        <div class="inner">
                            <h6 class="title">Location on Map</h6>
                            <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
                            <div id="l-map" style="width: 300px"></div>
                        </div>
                    </div>
                    <!-- Sidebar (Company Location) End -->
                </div>
            </div>
            <!-- Company Sidebar Wrap End -->

        </div>
    </div>
</div>
<!-- Company List End -->
<%--///////////////////////////////--%>
<script type="text/javascript" src="<%=path%>/assets/js/vendor/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
    $(function () {
        function getValue(pageNum){
            $.ajax({
                url:"<%=path%>/web/company/position",
                type:"post",
                data:{pageNum:pageNum,companyId:${requestScope.company.id}},
                success:function (data) {
                    $(".job-list-wrap").html(data);
                }
            });
        }
        $.each($("a[id^=page]"),function () {
            $(this).on("click",$(".job-list-wrap"),function () {
                var pageNum = $(this).attr("data-id");
                getValue(pageNum);
            })
        });
        $("#prePage").on("click",$(".job-list-wrap"),function () {
            var pageNum = $("#prePage").attr("data-id");
            if(pageNum<=0){
                pageNum = 1;
            }
            getValue(pageNum);
        });
        $("#nextPage").on("click",$(".job-list-wrap"),function () {
            var pageNum = $("#nextPage").attr("data-id");
            if(pageNum>${requestScope.pageInfo.pages}){
                pageNum = ${requestScope.pageInfo.pages};
            }
            getValue(pageNum);
        });
    });

    // 百度地图API功能
    function G(id) {
        return document.getElementById(id);
    }

    var map = new BMap.Map("l-map");
    var point = new BMap.Point(${requestScope.company.city.lng}, ${requestScope.company.city.lat});
    map.centerAndZoom(point,12);                   // 初始化地图,设置城市和地图级别。
    map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
    var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
        {"input" : "suggestId"
            ,"location" : map
        });

    ac.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
        var str = "";
        var _value = e.fromitem.value;
        var value = "";
        if (e.fromitem.index > -1) {
            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        }
        str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

        value = "";
        if (e.toitem.index > -1) {
            _value = e.toitem.value;
            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        }
        str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
        G("searchResultPanel").innerHTML = str;
    });

    var myValue;
    ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
        var _value = e.item.value;
        myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;

        setPlace();
    });

    function setPlace(){
        map.clearOverlays();    //清除地图上所有覆盖物
        function myFun(){
            var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
            map.centerAndZoom(pp, 18);
            map.addOverlay(new BMap.Marker(pp));    //添加标注
        }
        var local = new BMap.LocalSearch(map, { //智能搜索
            onSearchComplete: myFun
        });
        local.search(myValue);
    }
</script>
<jsp:include page="../inc/footer.jsp"></jsp:include>